package cn.iocoder.yudao.module.member.agency.mq;

import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.module.api.member.agency.message.AgencyAuditPassMessage;
import cn.iocoder.yudao.module.api.member.agency.message.AgencyOrderPaidMessage;
import cn.iocoder.yudao.module.api.member.agency.message.AgencyUserExpiredMessage;
import cn.iocoder.yudao.module.api.member.agency.vo.AgencyApplyVO;
import cn.iocoder.yudao.module.api.member.agency.vo.AgencyOrderVO;
import cn.iocoder.yudao.module.api.member.vip.message.VipUserExpiredMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 招商人员 事件生产者
 *
 * @author 山野羡民
 */
@Component
@Slf4j
public class AgencyProducer {

    /**
     * 发送 {@link AgencyAuditPassMessage} 消息
     *
     * @param apply 招商人员申请信息
     */
    public void sendAgencyAuditPassMessage(AgencyApplyVO apply) {
        log.info("[sendAgencyAuditPassMessage] ID#{}", apply.getId());
        SpringUtil.getApplicationContext().publishEvent(new AgencyAuditPassMessage(apply));
    }

    /**
     * 发送 {@link AgencyOrderPaidMessage} 消息
     *
     * @param order 交易订单信息
     */
    public void sendAgencyOrderPaidMessage(AgencyOrderVO order) {
        log.info("[sendAgencyOrderPaidMessage] {}", order.getTradeNo());
        SpringUtil.getApplicationContext().publishEvent(new AgencyOrderPaidMessage(order));
    }

    /**
     * 发送 {@link VipUserExpiredMessage} 消息
     *
     * @param userId 用户编号
     */
    public void sendAgencyUserExpiredMessage(Long userId) {
        log.info("[sendAgencyUserExpiredMessage] {}", userId);
        SpringUtil.getApplicationContext().publishEvent(new AgencyUserExpiredMessage(userId));
    }

}
